<?php
session_name(DicomScience);
session_start();
require('session.php');
require('html_head.php');
?>
<body onresize="resizeWindow()">

<script type="text/javascript" src="portalMain.js"></script>

<script>
	$(document).ready(function(){
		windowBase();
	});
	$.ui.dialog.defaults.bgiframe = true;
</script>
<div id="mainMenu">
	<div id="login">
	<?php
	if($_SESSION['userid'] == 0){
		// GuestMode: No user logged in - show login window
		echo "<img id=\"loginButton\" class=\"hiddenMenuItem\" src=\"./themes/$thdir/but_arr_down.png\" alt=\"Login\"/>";
	} else {
		// Logged in - shów logout window
		echo "<img id=\"logoutButton\" class=\"hiddenMenuItem\" src=\"./themes/$thdir/but_x_it.png\" alt=\"Logout\" />";
	}
	?>
	</div>
	<div id="userName">
		<?php 
		$firstname = $_SESSION['firstname'];
		$lastname = $_SESSION['lastname'];
		echo $firstname." ".$lastname.$nls_welcome_to_dicomscience; 
		?>
	</div>
	<div id="timeSelector">
		<?php echo $nls_select_portal_time; ?>
		<span id="portalTimeDummy">
		14
		</span>
		<select id="portalTimeSelector">
			<option>1</option>
			<option>7</option>
			<option selected>14</option>
			<option>31</option>
			<option>180</option>
			<option>365</option>
		</select>
		<?php echo $nls_select_portal_days; ?>
	</div>
	<div id='menuLibrary'><?php echo $nls_library;?></div>
	
	<?php
		if ($_SESSION['userid'] != 0){
			echo "<div id='reportView'>$nls_myReports</div>";
		}
	?>
	<?php
		if ($_SESSION['userid'] != 0){
			echo "<div id='caseView'>$nls_myCases</div>";
		}
	?>
	<!--<div>eigene Fälle, wenn eingeloggt</div>
	<div>Quizmode</div>-->
</div>

<div id="loginWindow">
	<form id="loginForm" method="POST" action="login.php">
		<input type="text" class="loginField" id="loginUsername" name="loginUsername" value="<?php echo $nls_username; ?>"/>
		<input type="password" class="loginField" id="loginPassword" name="loginPassword" value="<?php echo $nls_password; ?>"/>
		<input type="checkbox" class="loginCheckbox" name="setCookie" value="true" /><?php echo "$nls_set_Cookie"; ?>
		<input type="submit" class="loginFieldButton" name="loginSubmit" id="loginSubmit" value="<?php echo $nls_login; ?>">
		<input type="button" class="loginFieldButton" name="loginAbort" id="loginAbort" value="<?php echo $nls_abort; ?>">
	</form>			
</div>

<div id="portalBlog" name="portalBlog">
	<?php require('portalBlog.php');?>
</div>
<div id="portalCases" name="portalCases">
	<?php require('portalCases.php');?>
</div>
<div id="portalMedia" name="portalMedia">
	<?php require('portalMedia.php');?>
</div>

<?php
$auth = $_GET['auth']; // null or false
$noBrowser = $_SESSION['remoteBrowser'];
$noBrowserVersion  = $_SESSION['remoteBrowserVersion'];
	
	if ($auth == 'false'){
		
		if ($noBrowser == 'IE'){
			echo "<img src=\"./themes/$thdir/noaccess.png\" alt=\"authentification failed\" onclick=\"window.location.href = 'portalMain.php'\" />";
		} else {
			echo "<div id=\"accessDeniedOverlay\"";
			echo "<div id=\"accessDenied\">";
			echo "<img src=\"./themes/$thdir/noaccess.png\" alt=\"Login failed\" />";
			echo "</div>";
			echo "</div>";
			echo "<script type=\"text/javascript\">";
			echo "if (window.innerHeight){";
			echo "var height = window.innerHeight;";
			echo "} else {";
			echo "var height = document.documentElement.clientHeight;";
			echo "}";
			echo "if (window.innerWidth){";
			echo "var width = window.innerWidth;";
			echo "} else {";
			echo "var width = document.documentElement.clientWidth;";
			echo "}";
			echo "var nologin = document.getElementById(\"accessDenied\");";
			echo "nologin.style.position = \"absolute\";";
			echo "var posHorA = (window.innerWidth)/2 - 250;";
			echo "var posVerA = (window.innerHeight)/2 - 200;";
			echo "nologin.style.left = posHorA + \"px\";";
			echo "nologin.style.top = posVerA + \"px\";";
			echo "var overlay = document.getElementById(\"accessDeniedOverlay\");";
			echo "overlay.style.position = \"absolute\";";
			echo "overlay.style.left = \"0\";";
			echo "overlay.style.top = \"0\";";
			echo "overlay.style.width = width + \"px\";";
			echo "overlay.style.height = height + \"px\";";
			echo "\$(\"div#accessDenied,div#accessDeniedOverlay\").bind(\"click\", function(){";
			echo "self.location.href='portalMain.php';";
			echo "});";
			echo "</script>";
		}
	}

?>
<div id='overlayDiv'></div>
</body>
<?php
require('html_foot.php');
?>